package statistics;

import java.util.Random;


public class DiscreteUniformDistribution extends Distribution{

    protected int m;
    protected int n;
    
    public DiscreteUniformDistribution(int m  , int n, Random random ){
        this.m = m;
        this.n = n;
    }
            

    public double expectation() {
       return (m+n)/2.0;
    }


    public double variance() {
        return ((n-m+1)*(n-m+1)-1)/12.0;
    }


    public double nextRandom() {
        double U = random.nextDouble();
        return Math.floor(U*(n-m+1));
    }
    
    
}